import 'package:flutter/material.dart';

void openDialog(BuildContext context, String title, Widget contentWidget, Function okFunction) {
  showDialog(
    context: context,
    builder: (BuildContext context) {
      return AlertDialog(
        title: Text(title),
        content: contentWidget,
        actions: <Widget>[
          TextButton(
            child: const Text('取消'),
            onPressed: () {
              Navigator.of(context).pop();
            },
          ),
          TextButton(
            child: const Text('确定'),
            onPressed: () async {
              // 处理确定按钮的逻辑
              await okFunction();
              if (context.mounted) {
                Navigator.of(context).pop();
              }
            },
          ),
        ],
      );
    },
  );
}
